#pragma once
#include "Stdafx.h"
#include "Logger.h"
#include "Image.h"

namespace Pulpy
{
	class Terrain
	{
	private:
		GLubyte * _HeightMap;
		int _TerrainSize;
		float _MaxHeight;
		bool _RenderMesh;
		float _ScaleFactor;
		TextureImage _Image;
		void LoadHeightMap(char * filename);
	public:
		Terrain(char * heightmap, char * texture, int size, int maxheight): _TerrainSize(size), _RenderMesh(false), _MaxHeight(maxheight), _ScaleFactor(256.0f/maxheight)
		{ _HeightMap = new GLubyte[size*size]; LoadHeightMap(heightmap); LoadTGA(&_Image, texture); };
		~Terrain() { delete [] _HeightMap; }
		void toggleMeshMode() { _RenderMesh = !_RenderMesh; }
		void draw();
	};
}